package com.jeejam.product.dubbo;

import com.alibaba.dubbo.config.annotation.Service;
import com.jeejam.util.ShopBeanBuildUtil;
import com.jeejam.framework.base.pojo.TreePager;
import com.jeejam.product.pojo.Filter;
import com.jeejam.product.sdk.api.IFilterService;
import com.jeejam.product.sdk.dto.FilterDto;
import com.jeejam.product.service.FilterService;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by JACKEY on 2016/3/18.
 */
@Service(version = "1.0.0")
public class FilterDubboService implements IFilterService {

    @Resource
    private FilterService filterService;

    @Override
    public void save(FilterDto filterDto) {
        Filter filter = ShopBeanBuildUtil.slmCopyBean(filterDto, Filter.class);
        filterService.save(filter);
    }

    @Override
    public void update(FilterDto filterDto) {
        Filter filter = ShopBeanBuildUtil.slmCopyBean(filterDto, Filter.class);
        filterService.update(filter);
    }

    @Override
    public FilterDto getById(int id) {
        return filterService.findById(id);
    }

    @Override
    public List<FilterDto> selectRoot() {
        List<Filter> filterList = filterService.selectRoot();
        return ShopBeanBuildUtil.slmCopyBeanList(filterList, FilterDto.class);
    }

    @Override
    public List<FilterDto> selectRootWithoutChildren() {
        List<Filter> filterList = filterService.selectRootWithoutChildren();
        return ShopBeanBuildUtil.slmCopyBeanList(filterList, FilterDto.class);
    }

    @Override
    public List<FilterDto> selectRootByPage(int page, int pageSize) {
        List<Filter> filterList = filterService.selectRootByPage(page, pageSize);
        return ShopBeanBuildUtil.slmCopyBeanList(filterList, FilterDto.class);
    }

    @Override
    public List<FilterDto> selectChildren(int id) {
        List<Filter> filterList = filterService.selectChildren(id);
        return ShopBeanBuildUtil.slmCopyBeanList(filterList, FilterDto.class);
    }

    @Override
    public TreePager getTreePager(int currentPage, int pageSize) {
        return filterService.getTreePager(currentPage, pageSize);
    }

    @Override
    public int countsWithRoot() {
        return filterService.countsWithRoot();
    }

    @Override
    public void deleteWithChildren(int id) {
        filterService.deleteWithChildren(id);
    }
}
